package win32api_interface.memory.helper is

  --  This package contains simple calling routines to perform certain
  --  memory management operations.

  type FourBytes is new string(1..4);

  Read_Bytes_Error : exception;

  type addr_array is array (1..100) of Address;
  type results is record
    n: integer;
    pos: addr_array;
  end record;

  ------------------------------
  -- Memory Reading Functions --
  ------------------------------

  function Read_Bytes(HProc  : in Handle;
                      Target : in Address;
                      Length : in Integer) return string;
  -- Reads the bytes from a givern address and length

  function Follow_Pointer(HProc  : in Handle;
                          Target : in Address) return Address;
  -- Reads a 4 byte pointer to return a 4 byte address/pointer

  function Read_Int2bytes(HProc  : in Handle;
                          Target : in Address) return Integer;
  -- Reads a 2 byte integer from the given address

  function Read_Int1byte(HProc  : in Handle;
                         Target : in Address) return Integer;
  -- Reads a 1 byte integer from the given address

  ------------------------------
  -- Memory Writing Functions --
  ------------------------------

  procedure Write_Bytes(HProc  : in Handle;
                        Target : in Address;
                        Value  : in String);
  -- Writes the given string to the given address

  procedure Write_Int(HProc  : in Handle;
                      Target : in Address;
                      Value  : in Integer);
  -- Writes the given string to the given address

  ---------------------------------
  -- Memory Management Functions --
  ---------------------------------

  function Get_Memory_Status return MemoryStatus;

  function Get_Max_Virtual return Address;
  --  Returns the total virtual memeory space availible.

  function Min_App_Addr return Address;

  function Max_App_Addr return Address;

  function Find_Bytes(HProc : in Handle; Query : in String;
                      From  : in Address := Min_App_Addr;
                      To    : in Address := Max_App_Addr)
                      return Results;
  function Find_Pointer(HProc : in Handle; Query : in Address;
                        From  : in Address := Min_App_Addr;
                        To    : in Address := Max_App_Addr)
                        return Results;

  ------------------------------------
  -- Data Type Conversion Functions --
  ------------------------------------

  function fourbytes_to_float(four   : in fourbytes) return float;
  function float_to_fourbytes(num    : in float)     return fourbytes;
  function byte_to_integer   (inbyte : in character) return integer;
end win32api_interface.memory.helper;
